<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="120px">
      <el-form-item label="团队名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入团队名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="统一信用代码" prop="companyCard">
        <el-input
          v-model="queryParams.companyCard"
          placeholder="请输入统一信用代码"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="队伍名称" prop="teamName" v-if="false">
        <el-input
          v-model="queryParams.teamName"
          placeholder="请输入队伍名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="队伍类型" prop="teamCategory">
        <el-select v-model="queryParams.teamCategory" placeholder="请选择队伍类型" clearable>
          <el-option
            v-for="dict in cl_team_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="队伍描述" prop="teamDesc" v-if="false">
        <el-input
          v-model="queryParams.teamDesc"
          placeholder="请输入队伍描述"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="法人" prop="legalPerson">
        <el-input
          v-model="queryParams.legalPerson"
          placeholder="请输入法人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人" prop="leader">
        <el-input
          v-model="queryParams.leader"
          placeholder="请输入负责人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人联系方式" prop="leaderPhone">
        <el-input
          v-model="queryParams.leaderPhone"
          placeholder="请输入负责人联系方式"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="负责人身份证号" prop="leaderId" v-if="false">
        <el-input
          v-model="queryParams.leaderId"
          placeholder="请输入负责人身份证号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="主要联系人" prop="teamContacts">
        <el-input
          v-model="queryParams.teamContacts"
          placeholder="请输入主要联系人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="主要联系人电话" prop="teamPhone">
        <el-input
          v-model="queryParams.teamPhone"
          placeholder="请输入主要联系人电话"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="主要联系人" prop="teamContactsId" v-if="false">
        <el-input
          v-model="queryParams.teamContactsId"
          placeholder="请输入主要联系人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所在区域" prop="area" v-if="false">
        <el-select v-model="queryParams.area" placeholder="请选择所在区域" clearable>
          <el-option
            v-for="dict in cl_team_area"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="地址" prop="address" v-if="false">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入地址"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择审核状态" clearable>
          <el-option
            v-for="dict in cl_team_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8" v-if="false">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['ndpf:team:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ndpf:team:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ndpf:team:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['ndpf:team:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="teamList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" v-if="false"/>
      <el-table-column label="公司ID" align="center" prop="teamId" v-if="false"/>
      <el-table-column label="团队logo" align="center" prop="logo" width="100">
        <template #default="scope">
          <image-preview :src="scope.row.logo" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="服务类别" align="center" prop="serviceType" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_team_service_type" :value="scope.row.serviceType ? scope.row.serviceType.split(',') : []"/>
        </template>
      </el-table-column>
      <el-table-column label="密码(未启用)" align="center" prop="password" v-if="false"/>
      <el-table-column label="成立时间" align="center" prop="establishDated" />
      <el-table-column label="团队名称" align="center" prop="companyName" />
      <el-table-column label="统一信用代码" align="center" prop="companyCard" width="130"/>
      <el-table-column label="描述" align="center" prop="companyDesc" v-if="false"/>
      <el-table-column label="队伍名称" align="center" prop="teamName" v-if="false"/>
      <el-table-column label="队伍类型" align="center" prop="teamCategory" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_team_type" :value="scope.row.teamCategory"/>
        </template>
      </el-table-column>
      <el-table-column label="队伍口号" align="center" prop="teamSolo" v-if="false"/>
      <el-table-column label="队伍描述" align="center" prop="teamDesc" v-if="false"/>
      <el-table-column label="加入方式" align="center" prop="joinType" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_team_join_type" :value="scope.row.joinType"/>
        </template>
      </el-table-column>
      <el-table-column label="法人" align="center" prop="legalPerson" />
      <el-table-column label="负责人" align="center" prop="leader" />
      <el-table-column label="负责人联系方式" align="center" prop="leaderPhone" width="130"/>
      <el-table-column label="负责人身份证号" align="center" prop="leaderId" v-if="false"/>
      <el-table-column label="负责人身持证件照" align="center" prop="leaderIdPhoto" width="100" v-if="false">
        <template #default="scope">
          <image-preview :src="scope.row.leaderIdPhoto" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="主要联系人" align="center" prop="teamContacts" />
      <el-table-column label="主要联系人电话" align="center" prop="teamPhone" width="130"/>
      <el-table-column label="主要联系人身份证号" align="center" prop="teamContactsId" v-if="false"/>
      <el-table-column label="是否公开" align="center" prop="isPublicly">
        <template #default="scope">
          <dict-tag :options="cl_is_publicly" :value="scope.row.isPublicly"/>
        </template>
      </el-table-column>
      <el-table-column label="团队海报" align="center" prop="poster" width="100" v-if="false">
        <template #default="scope">
          <image-preview :src="scope.row.poster" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="团队照" align="center" prop="photo" width="100" v-if="false">
        <template #default="scope">
          <image-preview :src="scope.row.photo" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="邮箱" align="center" prop="email" v-if="false"/>
      <el-table-column label="经纬度" align="center" prop="lonlat" v-if="false"/>
      <el-table-column label="所在区域" align="center" prop="area" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_team_area" :value="scope.row.area"/>
        </template>
      </el-table-column>
      <el-table-column label="地址" align="center" prop="address" v-if="false"/>
      <el-table-column label="团队二维码" align="center" prop="qrcode" width="100" v-if="false">
        <template #default="scope">
          <image-preview :src="scope.row.qrcode" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="登记/审计的部门" align="center" prop="auditGroup" v-if="false"/>
      <el-table-column label="管理部门" align="center" prop="manageGroup" v-if="false"/>
      <el-table-column label="志愿者人数" align="center" prop="volunteerNums" />
      <el-table-column label="审核状态" align="center" prop="status">
        <template #default="scope">
          <dict-tag :options="cl_team_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" v-if="false"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250" >
        <template #default="scope">
          <el-button type="success" plain  @click="handleExamine(scope.row,'1')" v-hasPermi="['ndpf:team:edit']" size="small" v-if="scope.row.status === '0'">通过</el-button>
          <el-button type="warning" plain  @click="handleExamine(scope.row,'2')" v-hasPermi="['ndpf:team:edit']" size="small" v-if="scope.row.status === '0'">驳回</el-button>
          <el-button type="success" plain  @click="handleExamine(scope.row,'1')" v-hasPermi="['ndpf:team:remove']" size="small" v-if="scope.row.status === '1' || scope.row.status === '4'">启用</el-button>
          <el-button type="warning" plain  @click="handleExamine(scope.row,'4')" v-hasPermi="['ndpf:team:remove']" size="small" v-if="scope.row.status === '1'">停用</el-button>
          <el-button type="danger" plain  @click="handleDelete(scope.row)" v-hasPermi="['ndpf:team:remove']" size="small">删除</el-button>
          <el-button type="primary" plain  @click="handleUpdate(scope.row)" v-hasPermi="['ndpf:team:edit']" size="small">查看或修改</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改团队信息对话框 -->
    <el-dialog :title="title" v-model="open" width="1200px" append-to-body>
        <el-form ref="teamRef" :model="form" :rules="rules" label-width="150px">
        <el-row>
            <el-col :span="6">
                <el-form-item label="成立时间" prop="establishDated">
                    <el-date-picker clearable
                        v-model="form.establishDated"
                        type="date"
                        value-format="YYYY-MM-DD"
                        placeholder="请选择成立时间">
                    </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="团体名称" prop="teamName">
                    <el-input v-model="form.teamName" placeholder="请输入团体名称" />
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="公司名称" prop="companyName">
                    <el-input v-model="form.companyName" placeholder="请输入公司名称" />
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="统一信用代码" prop="companyCard">
                    <el-input v-model="form.companyCard" placeholder="请输入统一信用代码" />
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="团队logo" prop="logo">
                    <image-upload v-model="form.logo" :limit="1" :file-size="1"/>
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="团队海报" prop="poster">
                    <image-upload v-model="form.poster" :limit="1" :file-size="2"/>
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="团队照" prop="photo">
                    <image-upload v-model="form.photo" :limit="1" :fileSize="2"/>
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="营业执照" prop="businessLicense">
                    <image-upload v-model="form.businessLicense" :limit="1" :fileSize="2"/>
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="队伍类型" prop="teamCategory">
                    <el-select v-model="form.teamCategory" placeholder="请选择队伍类型">
                        <el-option
                        v-for="dict in cl_team_type"
                        :key="dict.value"
                        :label="dict.label"
                        :value="dict.value"
                        ></el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="18">
                <el-form-item label="队伍口号" prop="teamSolo">
                    <el-input v-model="form.teamSolo" placeholder="请输入队伍口号" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="法人" prop="legalPerson">
                    <el-input v-model="form.legalPerson" placeholder="请输入法人" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="加入方式" prop="joinType">
                <el-select v-model="form.joinType" placeholder="请选择加入方式">
                    <el-option
                    v-for="dict in cl_team_join_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    ></el-option>
                </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="邮箱" prop="email">
                <el-input v-model="form.email" placeholder="请输入邮箱" />
                </el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="队伍介绍" prop="teamDesc">
                  <el-input v-model="form.teamDesc" type="textarea" placeholder="请输入队伍介绍" :autosize="{ minRows: 6, maxRows: 20 }"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="负责人手持证件照" prop="leaderIdPhoto">
                <image-upload v-model="form.leaderIdPhoto" :limit="1" :file-size="2"/>  
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="负责人" prop="leader">
                <el-input v-model="form.leader" placeholder="请输入负责人" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="负责人联系方式" prop="leaderPhone">
                <el-input v-model="form.leaderPhone" placeholder="请输入负责人联系方式" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="负责人身份证号" prop="leaderId">
                <el-input v-model="form.leaderId" placeholder="请输入负责人身份证号" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="主要联系人" prop="teamContacts">
                <el-input v-model="form.teamContacts" placeholder="请输入主要联系人" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="主要联系人电话" prop="teamPhone">
                <el-input v-model="form.teamPhone" placeholder="请输入主要联系人电话" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="主要联系人身份证号" prop="teamContactsId">
                <el-input v-model="form.teamContactsId" placeholder="请输入主要联系人身份证号" />
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="是否公开" prop="isPublicly">
                <el-select v-model="form.isPublicly" placeholder="请选择是否公开">
                    <el-option
                    v-for="dict in cl_is_publicly"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    ></el-option>
                </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="6">
                <el-form-item label="所在区域" prop="area">
                <el-select v-model="form.area" placeholder="请选择所在区域">
                    <el-option
                    v-for="dict in cl_team_area"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                    ></el-option>
                </el-select>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="地址" prop="address">
                <el-input v-model="form.address" placeholder="请输入地址" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="登记/审计的部门" prop="auditGroup">
                <el-input v-model="form.auditGroup" placeholder="请输入登记/审计的部门" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
                <el-form-item label="管理部门" prop="manageGroup">
                <el-input v-model="form.manageGroup" placeholder="请输入管理部门" />
                </el-form-item>
            </el-col>
            <el-col :span="8">
            <el-form-item label="审核状态" prop="status">
            <el-select v-model="form.status" placeholder="请选择审核状态" aria-readonly="true">
                <el-option
                v-for="dict in cl_team_status"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
                ></el-option>
            </el-select>
            </el-form-item>
            </el-col>
            <el-form-item label="团队二维码" prop="qrcode" v-if="false">
            <image-upload v-model="form.qrcode"/>
            </el-form-item>
            <el-form-item label="备注" prop="remark" v-if="false">
            <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
            <el-form-item label="经度" prop="longitude" v-if="false">
            <el-input v-model="form.longitude" placeholder="请输入经度" />
            </el-form-item>
            <el-form-item label="纬度" prop="latitude" v-if="false">
            <el-input v-model="form.latitude" placeholder="请输入纬度" />
            </el-form-item>
            <el-form-item label="经纬度" prop="lonlat" v-if="false">
            <el-input v-model="form.lonlat" placeholder="请输入经纬度" />
            </el-form-item>
            <el-col :span="24">
                <el-form-item label="服务类别" prop="serviceType">
                    <el-checkbox-group v-model="form.serviceType">
                        <el-checkbox
                        v-for="dict in cl_team_service_type"
                        :key="dict.value"
                        :label="dict.value">
                        {{dict.label}}
                        </el-checkbox>
                    </el-checkbox-group>
                </el-form-item>
            </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Team">
import { listTeam, getTeam, delTeam, addTeam, updateTeam, modState } from "@/api/ndpf/team";

const { proxy } = getCurrentInstance();
const { cl_is_publicly, cl_team_type, cl_team_join_type, cl_team_area, cl_team_service_type, cl_team_status } = proxy.useDict('cl_is_publicly', 'cl_team_type', 'cl_team_join_type', 'cl_team_area', 'cl_team_service_type', 'cl_team_status');

const teamList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    companyName: null,
    companyCard: null,
    teamName: null,
    teamCategory: null,
    teamDesc: null,
    legalPerson: null,
    leader: null,
    leaderPhone: null,
    leaderId: null,
    teamContacts: null,
    teamPhone: null,
    teamContactsId: null,
    area: null,
    address: null,
    status: null,
  },
  rules: {
    serviceType: [
      { required: true, message: "服务类别不能为空", trigger: "blur" }
    ],
    establishDated: [
      { required: true, message: "成立时间不能为空", trigger: "blur" }
    ],
    teamName: [
      { required: true, message: "团体名称不能为空", trigger: "blur" }
    ],
    companyName: [
      { required: true, message: "公司名称不能为空", trigger: "blur" }
    ],
    teamCategory: [
      { required: true, message: "队伍类型不能为空", trigger: "change" }
    ],
    joinType: [
      { required: true, message: "加入方式不能为空", trigger: "change" }
    ],
    legalPerson: [
      { required: true, message: "法人不能为空", trigger: "blur" }
    ],
    leader: [
      { required: true, message: "负责人不能为空", trigger: "blur" }
    ],
    leaderPhone: [
      { required: true, message: "负责人联系方式不能为空", trigger: "blur" }
    ],
    leaderId: [
      { required: true, message: "负责人身份证号不能为空", trigger: "blur" }
    ],
    teamContacts: [
      { required: false, message: "主要联系人不能为空", trigger: "blur" }
    ],
    teamPhone: [
      { required: false, message: "主要联系人电话不能为空", trigger: "blur" }
    ],
    teamContactsId: [
      { required: false, message: "主要联系人身份证不能为空", trigger: "blur" }
    ],
    isPublicly: [
      { required: true, message: "是否公开不能为空", trigger: "change" }
    ],
    logo: [
      { required: true, message: "团队logo不能为空", trigger: "blur" }
    ],
    poster: [
      { required: false, message: "团队海报不能为空", trigger: "blur" }
    ],
    photo: [
      { required: false, message: "团队照不能为空", trigger: "blur" }
    ],
    email: [
      { required: false, message: "邮箱不能为空", trigger: "blur" }
    ],
    area: [
      { required: true, message: "所在区域不能为空", trigger: "change" }
    ],
    address: [
      { required: true, message: "地址不能为空", trigger: "blur" }
    ],
    status: [
      { required: true, message: "审核状态不能为空", trigger: "change" }
    ]
    ,businessLicense: [
      { required: true, message: "营业执照不能为空", trigger: "change" }
    ],
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询团队信息列表 */
function getList() {
  loading.value = true;
  listTeam(queryParams.value).then(response => {
    teamList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    teamId: null,
    serviceType: [],
    password: null,
    establishDated: null,
    companyName: null,
    companyCard: null,
    companyDesc: null,
    teamName: null,
    teamCategory: null,
    teamSolo: null,
    teamDesc: null,
    isCheck: null,
    isAudit: null,
    joinType: null,
    legalPerson: null,
    leader: null,
    leaderPhone: null,
    leaderId: null,
    leaderIdPhoto: null,
    teamContacts: null,
    teamPhone: null,
    teamContactsId: null,
    isPublicly: null,
    logo: null,
    poster: null,
    photo: null,
    longitude: null,
    latitude: null,
    email: null,
    lonlat: null,
    area: null,
    address: null,
    qrcode: null,
    auditGroup: null,
    manageGroup: null,
    volunteerNums: null,
    status: null,
    remark: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null
  };
  proxy.resetForm("teamRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.teamId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加团队信息";
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _teamId = row.teamId || ids.value
  getTeam(_teamId).then(response => {
    form.value = response.data;
    form.value.serviceType = (form.value.serviceType || '').split(",");
    open.value = true;
    title.value = "修改团队信息";
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["teamRef"].validate(valid => {
    if (valid) {
      form.value.serviceType = form.value.serviceType.join(",");
      if (form.value.teamId != null) {
        updateTeam(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addTeam(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _teamIds = row.teamId || ids.value;
  proxy.$modal.confirm('是否确认删除团队信息编号为"' + _teamIds + '"的数据项？').then(function() {
    return delTeam(_teamIds);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('ndpf/team/export', {
    ...queryParams.value
  }, `team_${new Date().getTime()}.xlsx`)
}

function handleExamine(row,st){
  let teamId = row.teamId;
  let userId = row.userId;
  let status = st;
  // 将变量转换为JSON对象
  const jsonData = {
    teamId: teamId,
    userId: userId,
    status: status
  };
  modState(jsonData).then(response => {
    proxy.$modal.msgSuccess("修改成功");
    getList();
  });
}

getList();
</script>
